<?php #//v.3.3.0
#///////////////////////////////////////////////////////
#//  COPYRIGHT 2004 Phpauction.org ALL RIGHTS RESERVED//
#///////////////////////////////////////////////////////


include "./includes/config.inc.php";
           if(isset($_COOKIE['USERLANGUAGE'])) {
  $USERLANG = $_COOKIE['USERLANGUAGE'];
} else {
  $USERLANG = $SETTINGS['defaultlanguage'];
}
                $TIME = mktime(date("H")+$SETTINGS['timecorrection'],date("i"),date("s"),date("m"), date("d"),date("Y"));

$NOW = date("YmdHis",$TIME);
      


$sql_count_upcoming = "SELECT * FROM PHPAUCTIONXL_auctions 
				WHERE  
				( closed='0')  
				AND ( suspended='0') 
				AND private='n' 
				AND	starts>=".$NOW." 
				ORDER BY id";
				
				$result1 = mysql_query($sql_count_upcoming);
$total_upcoming = mysql_num_rows($result1);

$sql_count_live = "SELECT * FROM PHPAUCTIONXL_auctions 
				WHERE  
				( closed='0')  
				AND ( suspended='0') 
				AND private='n' 
				AND	starts<=".$NOW." 
				ORDER BY id";
				
							$result2 = mysql_query($sql_count_live);
$total_live = mysql_num_rows($result2);	
				

$sql_count_closed = "SELECT * FROM PHPAUCTIONXL_auctions 
				WHERE  
				( closed='1')  
				AND ( suspended='0') 
				AND ( current_bid>'0')
        AND ( retail>'0') 
				AND	starts<=".$NOW." 
				ORDER BY id";
	
							$result3 = mysql_query($sql_count_closed);
$total_closed = mysql_num_rows($result3);	
		



#///////////////////////////////////////////////////////
#//  Categories Creation List & Select                 //
#///////////////////////////////////////////////////////


if($SETTINGS['catsorting'] == 'alpha') {
	$catsorting = " ORDER BY t.cat_name ASC";
} else {
	$catsorting = " ORDER BY sub_counter DESC";
}  




$TPL_categories_select = "

<SCRIPT LANGUAGE=JavaScript>

<!--
function openURL()
{

      // grab index number of the selected option
      selInd = document.categorypulldown.category.selectedIndex;

      // get value of the selected option
      goURL = document.categorypulldown.category.options[selInd].value;

      // redirect browser to the grabbed value (here a URL)
      top.location.href = goURL;

}

//-->
</SCRIPT>

           <form name=categorypulldown>
<SELECT NAME=category onChange=openURL(this.form)
SIZE=1 CLASS=categories_select_puldown_class id=categories_select_puldown_id >
<OPTION SELECTED VALUE=0> Choose Category</OPTION>
   
"; 



$TPL_categories_value = ""; 
$query = "select distinct c.cat_id,t.cat_name, c.sub_counter, c.cat_colour,c.cat_image, c.counter from PHPAUCTIONXL_categories c, PHPAUCTIONXL_cats_translated t 
          WHERE c.parent_id=0
          AND t.cat_id=c.cat_id
          AND t.lang='".$USERLANG."'
          $catsorting";
$result = mysql_query($query);
if(!$result) {
	MySQLError($query);
	exit;
	
	
} else {
	$num_cat = mysql_num_rows($result);
	$i = 0;
	
  $categories_graphic_select_menu = "
  <div id=\"all_cate_btn\" style=\"background: transparent url(images/category_pulldown_menu$USERLANG.jpg) no-repeat scroll right center; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;\">
			<div class=\"menu\">
			  	<ul>
				<li><a class=\"hide\" href=\"index.php\"></a>
				<!--[if lte IE 6]>

				<a href=\"#\">

				<table><tr><td>

				<![endif]-->
				<ul>";
  
  
  
    $TPL_categories_value = "<ul CLASS=categories_list_class id=categories_list_id >\n";
	 
  
  while($i < $num_cat && $i < $SETTINGS['catstoshow']) {
		$catlink="";
		$cat_id = mysql_result($result,$i,"cat_id");
		$cat_name = mysql_result($result,$i,"cat_name");
		$cat_name = html_entity_decode($cat_name, ENT_QUOTES, 'utf-8');
		$sub_count = intval(mysql_result($result, $i, "sub_counter"));
		$cat_colour = mysql_result($result, $i, "cat_colour");
		$cat_image = mysql_result($result, $i, "cat_image");
		$cat_counter = (int)mysql_result($result, $i, "counter" );
	/*	if ($sub_count!=0)
			$cat_counter = "(".$sub_count.")";
		else {
			$cat_counter = "";
		}   */
		$cat_url = "./browse.php?id=$cat_id";  
	/*	if ( $cat_image != "") {
			$catlink = "<A HREF=\"$cat_url\"><IMG SRC=\"$cat_image\" BORDER=0></a>";
		}     */
		$catlink .= "<A HREF=\"$cat_url\">$cat_name</A>"." ($cat_counter)";
		$catlink2 = "<A HREF=\"$cat_url\">$cat_name"." ($cat_counter)"."</A>";
		/*if ( $cat_colour != "") {
			$catlink = setsspan($catlink,"background-color:$cat_colour");
		} */
		$TPL_categories_value .= "<li>".$catlink."</li>\n";
		$categories_graphic_select_menu .= "<li style=\"margin-top: -5px;\">".$catlink2."</li>\n";
		$TPL_categories_select .= "<OPTION VALUE=$cat_url>$cat_name</OPTION>\n"; 
		
		
		
		
		$i++;
	}
	
	  $TPL_categories_value .= "<li><a href=search_live_auctions.php >".$MSG_25_0057."</a>(".$total_live.")</li>\n";
		$categories_graphic_select_menu .= "<li style=\"margin-top: -5px;\"><a href=search_live_auctions.php >".$MSG_25_0057." (".$total_live.")</a></li>\n";
		$TPL_categories_select .= "<OPTION VALUE=search_live_auctions.php >".$MSG_25_0057." (".$total_live.")</OPTION>\n"; 
		
	  $TPL_categories_value .= "<li><a href=search_upcoming_auctions.php >".$MSG_AJAX_ADMIN_GRAPHIC_INTERFACE_UPCOMING."</a>(".$total_upcoming.")</li>\n";
		$categories_graphic_select_menu .= "<li style=\"margin-top: -5px;\"><a href=search_upcoming_auctions.php >".$MSG_AJAX_ADMIN_GRAPHIC_INTERFACE_UPCOMING." (".$total_upcoming.")</a></li>\n";
		$TPL_categories_select .= "<OPTION VALUE=search_upcoming_auctions.php >".$MSG_AJAX_ADMIN_GRAPHIC_INTERFACE_UPCOMING." (".$total_upcoming.")</OPTION>\n"; 
		
		$TPL_categories_value .= "<li><a href=search_closed_auctions.php >".$CLOSED_AUCTIONS."</a>(".$total_closed.")</li>\n";
		$categories_graphic_select_menu .= "<li style=\"margin-top: -5px;\"><a href=search_closed_auctions.php >".$CLOSED_AUCTIONS." (".$total_closed.")</a></li>\n";
		$TPL_categories_select .= "<OPTION VALUE=search_closed_auctions.php >".$CLOSED_AUCTIONS." (".$total_closed.")</OPTION>\n"; 
		
		
	//		$TPL_categories_value .= "<li id=ddf ><a href=search_live_auctions.php></li>\n";
	//	$categories_graphic_select_menu .= "<li id=ddf ><a href=search_live_auctions.php></li>\n";
	//	$TPL_categories_select .= "<li id=ddf ><a href=search_live_auctions.php</li>\n"; 
    	$categories_graphic_select_menu .= "<li style=\"margin-top: 0px;\"><A style=\"background:url(images/1All_categories_last.gif) no-repeat; height:5px;\" HREF=\"\"></A></li>\n";
	
		  
		
	
	$TPL_categories_value .= "</ul>\n";
	 $TPL_categories_select .= "</SELECT></FORM>"; 
	   $categories_graphic_select_menu .= "</ul>
					<!--[if lte IE 6]>

					</td></tr></table>

					</a>

					<![endif]-->
				  	 </li>
			 </ul>	
		</div>
		</div>";
     
     
     
     $categories_list = $TPL_categories_value;
        $categories_select = $TPL_categories_select;

//echo $categories_list;  

//echo $categories_select;

}


?>
